/*
 * Copyright (C) 2005 Jimi Xenidis <jimix@watson.ibm.com>, IBM Corporation
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 *
 * $Id$
 */

/*
 * FPU persistence test
 */
#include <test.h>
#include <lpar.h>
#include <hcall.h>

uval
test_os(uval argc __attribute__ ((unused)),
	uval argv[] __attribute__ ((unused)))
{
	uval32 id = pinfo[1].lpid & 0xF;
	char s[2];

	/*
	 * Store id in floating-point unit once and for all.
	 */
	asm("fildl %0" : : "m" (id));

	for (;;) {
		int x;
		/*
		 * Retrieve value from floating-point unit and convert
		 * it to a printable character.
		 */
		asm("fistl %0" : "=m" (x) : );
		s[0] = x + '0';
		s[1] = '\0';

		hputs(s);
	}

	return 0;
}
